import request from '@/config/axios'

// ERP 物料 VO
export interface MaterialVO {
  // 编号
  id: number
  // 产品编号
  productId: number
  // 仓库编号
  warehouseId: number
  // 库存数量
  count: number
}

// ERP 物料 API
export const MaterialApi = {
  // 查询产品库存分页
  getMaterialPage: async (params: any) => {
    return await request.get({ url: `/erp/material/page`, params })
  },

  //查询物料入库
  getMaterialPages: async (params: any) => {
    return await request.get({ url: `/erp/material/page`, params })
  },
  //查询物料分类
  getMaterialCategoryPage: async (params: any) => {
    return await request.get({ url: `/erp/material-category/page`, params })
  },

  // 新增通用字段
  createStockConfig: async (data: StockConfigVO) => {
    return await request.post({ url: `/erp/sys-dict/create`, data })
  },

  // 查询通用字典分页
  getSysDictPage: async (params: any) => {
    return await request.get({ url: `/erp/sys-dict/page`, params })
  },
  // 修改通用字典分类
  updateSysDict: async (data: StockConfigVO) => {
    return await request.put({ url: `/erp/sys-dict/update`, data })
  },

  // 删除通用字典分类
  deleteSysDict: async (id: number) => {
    return await request.delete({ url: `/erp/sys-dict/delete?id=` + id })
  },
  // 删除多个字典
  deleteSysDictList: async (ids: any[]) => {
    return await request.delete({ url: `/erp/sys-dict/delete-list`, params: { ids: ids.join(',') } })
  },

  // 查询通用字典详情
  getSysDict: async (id: number) => {
    return await request.get({ url: `/erp/sys-dict/get?id=` + id })
  },

  // 导出产品库存明细 Excel
  exportSysDict: async (params) => {
    return await request.download({ url: `/erp/sys-dict/export-excel`, params })
  },
  // 查询产品分页
  getMartaialPage: async (params: any) => {
    return await request.get({ url: `/erp/stock/page`, params })
  },
  // 查询产品库存详情
  getStock: async (id: number) => {
    return await request.get({ url: `/erp/stock/get?id=` + id })
  },

  // 查询产品库存详情
  getStock2: async (productId: number, warehouseId: number) => {
    return await request.get({ url: `/erp/stock/get`, params: { productId, warehouseId } })
  },

  // 获得产品库存数量
  getStockCount: async (productId: number) => {
    return await request.get({ url: `/erp/stock/get-count`, params: { productId } })
  },

  // 导出产品库存 Excel
  exportStock: async (params) => {
    return await request.download({ url: `/erp/stock/export-excel`, params })
  }
}
